<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * 客户端调用
 * @author Administrator
 *
 */ 
class nusoapClient extends Controller{
    var $client = null;
    function nusoapClient(){
        parent::Controller();
        $this->load->library('Nusoap');
        //$url = 'http://172.28.216.8/services/ProjectService?wsdl';
        $url = 'http://www.rmp.com/nusoapServer/index/wsdl';
        //$url = 'http://www.dflpvmkt.com.cn/rmp2015_new2_demo/index.php/nusoapServer/index/wsdl';
        $this->client = new mynusoap_client($url, true);
        $this->client->soap_defencoding = 'UTF-8';
        $this->client->decode_utf8      = false;
        $this->client->xml_encoding     = 'UTF-8';
    }
    /**
     * 测试
     */
    function test(){
        //参数转为数组形式传递
        $paras = array('name'=>'Bruce Lee');
        //目标方法没有参数时，可省略后面的参数
        $this->client->call('GetTestStr', $paras);
        $err = $this->client->getError();
        if (!$err){
            $document = $this->client->document;
            echo $document;
        }else{
            echo $err;
            exit();
        }
    }
    /**
     * 测试XML解析类
     */
    function testXml(){
        $xml = file_get_contents('temp.xml');
        $this->load->library('XMLParserLib');
        $parser = new XMLParser($xml);
        $parser->Parse();
        print_r($parser->document->globalinfo);
        //echo $parser->GenerateXML();
    }
    /**
     * 生成xml文件
     */
    function createXml() {
        $this->load->library('XMLParserLib');
        echo '<?xml version=\'1.0\' encoding=\'UTF-8\' ?>';
        $xml = new XMLTag('movies', array('version'=>'1.0','type'=>'documentary','encoding'=>'UTF-8'));
        $xml->AddChild('movie', array(), 1);
        echo $xml->GetXML();
    }
}